package org.springcloud.wisdom.amusement.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springcloud.wisdom.amusement.entity.Notice_Student;

import java.util.List;

@Mapper
public interface Notice_StudentDao extends BaseMapper {

    //获取某个社团所有报名活动的学生信息
    @Select("SELECT ns.id,s.sid, s.sname,s.sgender,s.sdept,s.smail,s.talent, n.content " +
            "FROM student s " +
            "INNER JOIN notice_student ns ON s.sid = ns.sid " +
            "INNER JOIN notice n ON ns.noticeid = n.id " +
            "WHERE ns.teamid =#{teamid}; ")
    public List<Notice_Student> getSignStudent(Integer teamid);
    @Select("SELECT ns.id,s.sid, s.sname,s.sgender,s.sdept,s.smail,s.talent, n.content " +
            "FROM student s " +
            "INNER JOIN notice_student ns ON s.sid = ns.sid " +
            "INNER JOIN notice n ON ns.noticeid = n.id " +
            "WHERE ns.teamid =#{teamid}; ")
    IPage<Notice_Student> getSignStudentPage(Page<?> page,Integer teamid);
    //报名
    @Insert("insert into notice_student(teamid,sid,noticeid) VALUES(#{teamid},#{sid},#{noticeid})")
    public int addSignStudent(Integer teamid,String sid,Integer noticeid);

    //报名成功
    @Update("update notice_student set ispermit=1 where id=#{id}")
    public int signSuccess(Integer id);

    //报名失败
    @Update("update notice_student set ispermit=2 where id=#{id}")
    public int signFail(Integer id);
}
